/*
 * @Author: 周润玉|zhourunyu1@outlook.com(zhourunyu)
 * @Date: 2022-03-24
 * @LastEditors: 周润玉|zhourunyu1@outlook.com(zhourunyu)
 * @LastEditTime: 2022-07-14 11:00:49
 * @Description: 
 * @Administrator: 周润玉|zhourunyu1@outlook.com(zhourunyu)
 * @Copyright: 文件版本号
 */

import doT from '../../../vendor/template/doT.js';
import { getAuthZ, TEST_NUMBER, TEST_INFO_NUMBER, Collaboration_APP, Service_APP } from '../../../../public/js/config/config.js';

/**
 *@file意见反馈
 *@Date :2022-03-24 13:26:28
 *@create周润玉
*/
(function (window, document, $) {
    'use strict';
    $('body').attr('data-weui-theme', 'light'); // 强制光明模式
    $('#application-date').text(`2019-${new Date().getFullYear()}`);

    let _vm;
    const _json = Utils.ParsingUrl(window.location);

    $(function () {
        _vm = new Vue({
            el: "#check-category",
            data() {
                return {
                    uploadCount: 0,
                    images: [],///处理weui自带上传插件回显重新上传时的问题
                }
            },
            methods: {
                truckLoadingTime: function (param) {
                    // 保存当前的滚动距离
                    scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
                    // 设置 fixed 布局
                    document.body.style.position = 'fixed';
                    document.body.style.height = '100%';
                    document.body.style.width = '100%';
                }
            }
        });

        initCommand();
        $(document).on('mousedown', '.clearContent', function (e) {
            e.target.style.fontSize = '16px'
        });
        $(document).on('focus', '.clearContent', function (e) {
            e.target.style.fontSize = '16px'
        });
    });

    /**
     *@file 命令初始化
     *@Date :2022-05-27 10:40:57
     *@create周润玉
    */
    const initCommand = () => {
        $.ajax({
            url: "../../../../public/datas/ctn/feedbackconfig.json",
            type: "GET",
            dataType: "json",
            success: function (res) {
                if (res.isSucceed == true) {
                    $('#radioType').empty();
                    res.data.forEach(element => {
                        let html = '';
                        if (element.id == _json.type) {
                            html =
                                '<label class="weui-cell weui-check__label">' +
                                '<div class="weui-cell__bd">' +
                                '<p>' + element.name + '</p>' +
                                '</div>'+
                                '<div class="weui-cell__ft">' +
                                '<input type="radio" name="radio1" class="weui-check" id="' + element.id + '" data-name="' + element.name + '" checked="checked">' +
                                '<span class="weui-icon-checked"></span>'
                                '</div></label>';
                        }else{
                            html =
                                '<label class="weui-cell weui-check__label">' +
                                '<div class="weui-cell__bd">' +
                                '<p>' + element.name + '</p>' +
                                '</div>'+
                                '<div class="weui-cell__ft">' +
                                '<input type="radio" name="radio1" class="weui-check" id="' + element.id + '" data-name="' + element.name + '">' +
                                '<span class="weui-icon-checked"></span>'
                                '</div></label>';
                        }
                        $('#radioType').append(html);
                    });
                }
            },
            error: function (e) {
                console.error(e);
            }
        });

        //点击确定按钮
        $('#confirmSubmit').on('click',function(){
            let checkType = $('#radioType').find('input:checked')[0];
             let textShow = checkType.dataset.name;
             let id=checkType.id;

             location.href = '../feedback/feedback.html?category=' + textShow+'&id=' + id+'&state=' + _json.state+'';
        });
    };

})(window, document, jQuery)